AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')

function ENT:Initialize()
	self.Entity:SetModel( self.DefaultModel )
	
	if self.Entity.DamageType == "normal" then
		self.Entity.Damage = 50
	else
		self.Entity.Damage = 100
	end
	
	self.Cooldown = 1
	self.EnergyDraw = 5
	
	self.BaseClass.Initialize(self)
end

function ENT:DrawBeam(hitposition, hitentity, hitnormal)
	if (self.DamageType == "normal") then
		CDEffect_beam_attached(self.Entity, hitposition, self.Color, 50, 0.2, 1, 1)
		CDEffect_impact_nonsolid(hitposition, self.Entity.Color, 100, 0.5, 0.2, hitnormal, hitentity)
	elseif (self.DamageType == "destructive") then
		CDEffect_beam_attached(self.Entity, hitposition, self.Color, 50, 0.2, 1, 1)
		CDEffect_beam_attached(self.Entity, hitposition, self.Color, 25, 0.2, 0.5, 2)
		CDEffect_impact_nonsolid(hitposition, self.Entity.Color, 100, 0.5, 0.2, hitnormal, hitentity)
	elseif (self.DamageType == "anti-shield") then
		CDEffect_beam_attached(self.Entity, hitposition, self.Color, 2, 0.2, 1, 3)
		CDEffect_beam_attached(self.Entity, hitposition, self.Color, 50, 0.2, 0.5, 1)
		CDEffect_impact_nonsolid(hitposition, self.Entity.Color, 100, 0.5, 0.2, hitnormal, hitentity)
	end
end

function Pulsed_Beam_Duplicate(player, position, angles, DamageType, Color)
	local newentity = ents.Create("weapon_beam_pulsed")
	newentity:SetPos(position)
	newentity:SetAngles(angles)
	newentity:SetPlayer(player)
	newentity.DamageType = DamageType
	newentity.Color = Color
	newentity:Spawn()
	return newentity
end

duplicator.RegisterEntityClass("weapon_beam_pulsed", Pulsed_Beam_Duplicate, "pos", "ang", "DamageType", "Color")